package ZuoYe.J;

import Ad.Aadw;

import java.util.*;

public class DouDiZhuGame {
    public static String[] type = {"♦", "♣", "♥", "♠"};
    public static String[] point = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
    public static String[] point1 = {"大王","小王"};
    public static HashMap hashMap = new HashMap();
    public static List<Puke> list = new ArrayList();
    public static ArrayList<Integer> arrayList = new ArrayList<>();
    public static LinkedList<Puke> newPokers = new LinkedList<>();
    /**
     * 将54张扑克牌初始化并放在对应的集合里面
     */
    public static void init(){
        for (int i = 0;i < type.length;i++){
            for (int j = 0;j < point.length;j++){
             list.add(new Puke(type[i],point[j]));
            }
        }
        list.add(new Puke(point1[0],point1[0]));
        list.add(new Puke(point1[1],point1[1]));
        for (int i = 0;i < list.size();i++){
            hashMap.put(i+1,list.get(i));
        }
    }

    /**
     * 洗牌
     */
    public static void xipai(){
        Set<Map.Entry<Integer, Puke>> set = hashMap.entrySet();
        Iterator it = set.iterator();
        while (it.hasNext()) {
            Map.Entry<Integer, Puke> e = (Map.Entry<Integer, Puke>) it.next();
            arrayList.add(e.getKey());
        }
        Collections.shuffle(arrayList);
        for (Integer i : arrayList) {
            newPokers.add((Puke) hashMap.get(i));
        }
    }

    /**
     * 发牌
     */
    public static void send(){
        List list = new ArrayList();
        List list1 = new ArrayList();
        List list2 = new ArrayList();
        List list3 = new ArrayList();
        for (int i = 0;i < newPokers.size();i++){
            if (i+1<=51) {
                if ((i+1)%3==1){
                    list.add(newPokers.get(i));
                }else if ((i+1)%3==2){
                    list1.add(newPokers.get(i));
                }else {
                    list2.add(newPokers.get(i));
                }
            }else {
                list3.add(newPokers.get(i));
            }

        }
        System.out.println("第一个人：" + list);
        System.out.println("第二个人：" + list1);
        System.out.println("第三个人：" + list2);
        System.out.println("底牌：" + list3);
    }

    public static void main(String[] args) {
        init();
        System.out.println(list);
        xipai();
        System.out.println(newPokers);
        send();

    }
}
